<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">

      <tr>
        <td style="width:90px;text-align: right;padding-top: 80px;">基本信息:</td>
        <td>
          <p style="float: left;">


            更新时间111：<span id="updateTime">
           {{ result.updateTime }}
                    </span><br>


            项目区域id：<span id="regionId">
           {{ result.regionId }}
                    </span><br>


            项目id：<span id="projectId">
           {{ result.projectId }}
                    </span><br>


            项目名称：<span id="projectName">
           {{ result.projectName }}
                    </span><br>


            楼层：<span id="floor">
           {{ result.floor }}
                    </span><br>


            门牌号：<span id="houseNum">
           {{ result.houseNum }}
                    </span><br>


            门牌号前缀：<span id="houseNumPre">
           {{ result.houseNumPre }}
                    </span><br>


            备注：<span id="remark">
           {{ result.remark }}
                    </span><br>

            创建时间：<span id="createTime">
           {{ result.createTime }}
                    </span><br>
          </p>
        </td>
      </tr>

      <tr>
        <td style="width:90px;text-align: right;padding-top: 60px;">详情:</td>
        <td>
          <p style="float: left;">


          </p>
        </td>
      </tr>

      <tr>
        <td style="text-align: center;" colspan="10">
          <a-button type="primary" @click="close">关闭</a-button>
        </td>
      </tr>
    </table>

  </a-modal>
</template>

<script>
import {httpAction} from '@/api/manage'
import pick from 'lodash.pick'
import moment from "moment"

export default {
  name: "HousesModal",
  data() {
    return {
      title: "操作",
      visible: false,
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      result: {},
      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {
        projectId: {rules: [{required: true, message: '请输入项目id!'}]},
      },
      url: {
        add: "/houses/houses/add",
        edit: "/houses/houses/edit",
      },
    }
  },
  created() {
  },
  methods: {
    add() {
      this.edit({});
    },
    edit(record) {
      Object.assign(this.result, record);
      this.visible = true;
    },
    close() {
      this.$emit('close');
      this.visible = false;
    },
    handleOk() {
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          let formData = Object.assign(this.model, values);
          //时间格式化
          formData.updateTime = formData.updateTime ? formData.updateTime.format('YYYY-MM-DD HH:mm:ss') : null;

          httpAction(httpurl, formData, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
            that.close();
          })


        }
      })
    },
    handleCancel() {
      this.close()
    },


  }
}
</script>

<style lang="less" scoped>

</style>